export {};

// interface EatAndRun {
//     eat(food: string): void;
//     run(distance: number): void;
// }
interface Eat {
    eat(food: string): void;
}
interface Run {
    run(distance: number): void;
}

class Person implements Eat, Run {
    eat(food: string): void {
        console.log(`优雅的进餐:${food}`);
    }
    run(distance: number): void {
        console.log(`直立行走: ${distance}`);
    }
}

abstract class Animal {
    eat(food: string): void {
        console.log(`咕噜咕噜的吃:${food}`);
    }
    run(distance: number): void {
        console.log(`爬行: ${distance}`);
    }
}

// 抽象类 abstract 只能继承 不能创建实例

// 泛型 Generics
// function createNumberArray(length: number, value: number): number[] {
//     const arr = Array<number>(length).fill(value)
//     return arr
// }
// function createStringArray(length: number, value: string): string[] {
//     const arr = Array<string>(length).fill(value)
//     return arr
// }
function createArray<T>(length: number, value: T): T[] {
    const arr = Array<T>(length).fill(value)
    return arr
}

const res = createArray<number>(3, 100)
const res1 = createArray<string>(3, 'a')